home *** CD-ROM | disk | FTP | other *** search
- Path: cs.mu.OZ.AU!bounce-back
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.std.c++
- Subject: Re: Use of standard exception classes
- Date: 18 Apr 96 00:54:30 GMT
- Organization: Datalytics, Inc
- Approved: fjh@cs.mu.oz.au
- Message-ID: <31756177.EB7@datalytics.com>
- References: <9604121530.AA08606@sun132.spd.dsccc.com> <BGLENDEN.96Apr12135956@colobus.aoc.nrao.edu>
- NNTP-Posting-Host: mundook.cs.mu.oz.au
- X-Original-Date: Wed, 17 Apr 1996 17:24:07 -0400
- X-Mailer: Mozilla 2.0 (WinNT; I)
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMXWSzOEDnX0m9pzZAQETwwF9FGCpj5Zh8nI6u/ST1ImUnBaUs3Qiuh+8
- JN+5WxgRXNXv+SfbgG4RnShuezDPSKig
- =apeb
- Originator: fjh@mundook.cs.mu.OZ.AU
-
- Brian Glendenning wrote:
- >
- > In a different topic, I'm confused about the different purpose ascribed to
- > exceptions derived from logic_error:
- > [snip]
- >
- > and runtime_error:
- > [snip]
- >
- > It seems to me that with this wording most exceptions should be derived from
- > runtime_error.
- > However, basic_string<...>::remove(size_type pos = 0, size_type n = npos),
- > for example, throws out_of_range (derived from logic error).
- >
- > Unless the program only runs with manifest constants, it can't detect this
- > problem before the program executs:
- > cin >> pos; mystring.remove(pos);
- >
- > So why does it throw a logic_error rather than a runtime_error? Thanks!
- >
- > (I'm also interested in learning whether it's a good idea to derive our
- > exceptions from standard exceptions).
- >
-
- Your code should have encountered that condition during
- development, or you should have seen it coming, so you should
- have logic built in to supply correct values to remove in all
- cases.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-